package com.huike.web.controller.report;


import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 首页简报getTodayInfo
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() {
        //获得当天时间
        Date today = new Date();
        //日期格式化
        SimpleDateFormat startFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        SimpleDateFormat endFormat = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
        //开始时间
        String start = startFormat.format(today);
        //结束时间
        String end = endFormat.format(today);
        return AjaxResult.success(reportService.getTodayInfo(start,end));
    }

    /**
     * 待办数据统计接口
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getToInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getToInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 首页--商机转化龙虎榜接口
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(@RequestParam("beginCreateTime") String beginCreateTime,
                                                @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.businessChangeStatistics(beginCreateTime, endCreateTime));
    }

    /**
     * 首页--线索转化龙虎榜接口
     */
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(@RequestParam("beginCreateTime") String beginCreateTime,
                                               @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.salesStatistic(beginCreateTime, endCreateTime));
    }


}
